<script>
//catch
Promise.prototype.catch = function(func){
    return this.then(null, func)
}
//resolve
Promise.resolve = function(value){
    return new Promise((resolve, reject) => {
        resolve(value)
    })
}
//Promise.all
Promise.all = function(promiseArr){
    if(!Array.isArray(promiseArr)){
        throw new TypeError('the arguments should be an array')
    }
    return new Promise((resolve, reject) => {
        let resolveArr = []
        promiseArr.forEach(item => {
            item.then(value =>{
                resolveArr.push(value)
                if(resolveArr.length === promiseArr.length){
                    resolve(resolveArr)
                }
            } ,reject)
        })     
    })
    
}
//Promise.race
Promise.race = function(promiseArr){
    if(!Array.isArray(promiseArr)){
        throw new TypeError('the arguments should be an array')
    }
    return new Promise((resolve, reject) => {
        promiseArr.forEach(item => {
            item.then(resolve, reject)
        })
    })
}

</script>